<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./productionReport.xhtml">

            <ui:define name="tabContent">

                <h:form>
                    <h:panelGrid columns="2">
                        Thời gian:
                        <h:panelGrid id="calendarGrid" columns="4">
                            Từ ngày 
                            <p:calendar value="#{productionByShortCodeBean.startDate}" pattern="dd/MM/yyyy" timeZone="Asia/Saigon" navigator="true"
                                        required="true" requiredMessage="Bạn chưa chọn ngày bắt đầu"/>
                            Đến ngày
                            <p:calendar value="#{productionByShortCodeBean.endDate}" pattern="dd/MM/yyyy" timeZone="Asia/Saigon" navigator="true"
                                        required="true" requiredMessage="Bạn chưa chọn ngày kết thúc"/>
                        </h:panelGrid>

                        Sub CP:
                        <p:selectOneMenu value="#{productionByShortCodeBean.selectedUsername}">
                            <f:selectItems value="#{userCmdCodeBean.legalSubCpMap}"/>
                            <p:ajax update="lblShortCode selShortCode" event="change" process="@this"/>
                        </p:selectOneMenu>

                        <h:panelGrid id="lblShortCode">
                            <h:outputText value="Đầu số" rendered="#{productionByShortCodeBean.selectedUsername == 'all'}"/>
                        </h:panelGrid>
                        <h:panelGrid id="selShortCode">
                            <p:selectOneMenu value="#{productionByShortCodeBean.selectedShortCode}" rendered="#{productionByShortCodeBean.selectedUsername == 'all'}">
                                <f:selectItem itemLabel="6071" itemValue="6071"/>
                                <f:selectItem itemLabel="6171" itemValue="6171"/>
                                <f:selectItem itemLabel="6271" itemValue="6271"/>
                                <f:selectItem itemLabel="6371" itemValue="6371"/>
                                <f:selectItem itemLabel="6471" itemValue="6471"/>
                                <f:selectItem itemLabel="6571" itemValue="6571"/>
                                <f:selectItem itemLabel="6671" itemValue="6671"/>
                                <f:selectItem itemLabel="6771" itemValue="6771"/>
                            </p:selectOneMenu>
                        </h:panelGrid>


                        <p:commandButton ajax="false" value="Xem báo cáo" action="#{productionByShortCodeBean.report()}" onclick="processingDialog.show()"
                                         onsuccess="processingDialog.hide()"/>
                        <p:commandButton ajax="false" value="Xem hôm nay" action="#{productionByShortCodeBean.reportByToday()}" immediate="true" onclick="processingDialog.show()"
                                         onsuccess="processingDialog.hide()"/>
                    </h:panelGrid>
                </h:form>
                <br/>
                <h:form id ="resultTableForm">
                    <p:dataTable id="tblByDay" value="#{productionByShortCodeBean.productionDays}" var="monthItem"
                                 rendered="#{productionByShortCodeBean.productionDays != null and productionByShortCodeBean.productionDays.size() > 0}">

                        <p:column headerText="Mạng" sortBy="#{monthItem.opertator}">
                            #{monthItem.opertator}
                        </p:column>
                        <p:column headerText="6071" sortBy="#{monthItem.p6071}">
                            #{monthItem.p6071}
                        </p:column>
                        <p:column headerText="6171" sortBy="#{monthItem.p6171}">
                            #{monthItem.p6171}
                        </p:column>
                        <p:column headerText="6271" sortBy="#{monthItem.p6271}">
                            #{monthItem.p6271}
                        </p:column>
                        <p:column headerText="6371" sortBy="#{monthItem.p6371}">
                            #{monthItem.p6371}
                        </p:column>
                        <p:column headerText="6471" sortBy="#{monthItem.p6471}">
                            #{monthItem.p6471}
                        </p:column>
                        <p:column headerText="6571" sortBy="#{monthItem.p6571}">
                            #{monthItem.p6571}
                        </p:column>
                        <p:column headerText="6671" sortBy="#{monthItem.p6671}">
                            #{monthItem.p6671}
                        </p:column>
                        <p:column headerText="6771" sortBy="#{monthItem.p6771}">
                            #{monthItem.p6771}
                        </p:column>
                    </p:dataTable>

                    <p:dataTable id="tblAllSubCp" value="#{productionByShortCodeBean.allSubCpProductions}" var="allSubCpItems"
                                 rendered="#{productionByShortCodeBean.allSubCpProductions != null and productionByShortCodeBean.allSubCpProductions.size() > 0}">

                        <p:column headerText="Sub CP" sortBy="#{allSubCpItems.subCpName}">
                            #{allSubCpItems.subCpName}
                        </p:column>
                        <p:column headerText="Mobifone" sortBy="#{allSubCpItems.productionOfMobifone}">
                            #{allSubCpItems.productionOfMobifone}
                        </p:column>
                        <p:column headerText="Vinaphone" sortBy="#{allSubCpItems.productionOfVinaphone}">
                            #{allSubCpItems.productionOfVinaphone}
                        </p:column>
                        <p:column headerText="Viettel" sortBy="#{allSubCpItems.productionOfViettel}">
                            #{allSubCpItems.productionOfViettel}
                        </p:column>
                        <p:column headerText="Tổng">
                            #{allSubCpItems.productionOfViettel + allSubCpItems.productionOfVinaphone + allSubCpItems.productionOfMobifone}
                        </p:column>
                    </p:dataTable>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>


